
import './App.scss';
import { Routes, Route } from 'react-router-dom';
import Login from '@/views/Login';
import Layout from '@/views/layout/Layout';
import { Navigate } from 'react-router-dom';
import { useAppSelector } from '@/store/hooks';
function App() {
  // 获取本地的token 
  // let token = store.get('token');
  // console.log('token', token);
  // 通过获取redux 中到存的token 
  const token = useAppSelector(state => state.user.userinfo.token)
  // console.log('token', token);

  return (
    <div className="App">
      {/* 配置一级路由规则 */}
      <Routes>
        <Route path='/login' element={token ? <Navigate to='/home'></Navigate> : <Login></Login>}></Route>
        {/*Layout为一级组件, 因为该一级组件有二级等后代路由, 所以,需要 path设置/* */}
        <Route path='/*' element={token ? <Layout></Layout> : <Navigate to='/login'></Navigate>}></Route>
      </Routes>
    </div>
  );
}

export default App;
